Skip to main content
Version: 1.0.0

Pie Chart

Illustrates the proportion of each category within a whole. Each slice of the pie represents a category, and the size of the slice corresponds to the proportion of that category within the whole. Pie charts are often used for simple comparisons of relative sizes, such as market share, budget allocation, or demographic composition.

Chart:


Code:

  const { muze, getDataFromSearchQuery } = viz;
  
  const data = getDataFromSearchQuery();

  const ColorField = "Origin";
  const RadiusField = "Miles_per_Gallon";
  const AngleField = "Cylinders";

  muze
    .canvas()
    .layers([
        {
            mark: "arc",
            encoding:{
                color: ColorField,
                radius: RadiusField,
                angle: AngleField,
                text: AngleField,
            },
        },
    ])
    .data(data)
    .mount("#chart") // mount your chart